package com.bloody.android;

import android.content.Context;
import android.content.res.Resources;
import android.graphics.Bitmap;
import android.graphics.Canvas;
import android.graphics.drawable.Drawable;
import android.util.AttributeSet;
import android.util.Log;
import android.view.View;

public class IntroView extends View{
	
	private Context context;
	private int height;
	private int width;
	private Bitmap bitmap;
	private BloodyCrusade bc;

	public IntroView(Context context, AttributeSet attrs) {
			super(context, attrs);
			this.context= context;
			Log.d("TAG", "test2");
	}
	
	public void setBc(BloodyCrusade bc) {
		this.bc = bc;
	}
	
	protected void onSizeChanged(int w, int h, int oldw, int oldh) {
			
			this.height=h;
			this.width=w;
			init();
	}
	
	public void init() {
		Resources r = context.getResources();
		Drawable tile = r.getDrawable(R.drawable.bcintro);
        bitmap = Bitmap.createBitmap(width, height/4, Bitmap.Config.ARGB_8888);
        Canvas canvas = new Canvas(bitmap);
        tile.setBounds(0, 0, width, height/4);
        tile.draw(canvas);
        this.bc.init();
        this.invalidate();
	}
	
	@Override
	public void onDraw(Canvas canvas) {
	    super.onDraw(canvas);
	    
	    canvas.drawBitmap(bitmap, 
	            0,
	            height/2-height/8,
	            null);
	}

}

